home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / qmgr / op_chan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  4.7 KB  |  207 lines

  1. /* op_chan.c: channel ROS operation routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/op_chan.c,v 6.0 1991/12/18 20:23:58 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/qmgr/RCS/op_chan.c,v 6.0 1991/12/18 20:23:58 jpo Rel $
  9.  *
  10.  * $Log: op_chan.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:58  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include "util.h"
  17. #include "qmgr-int.h"
  18. #include "consblk.h"
  19. #include "Qmgr-types.h"
  20. #include <isode/cmd_srch.h>
  21. #include <isode/rosap.h>
  22.  
  23. extern char    *mystrtotime();
  24.  
  25. static ChannelInfo *convert_ChanReadResult();
  26. static ChannelInfo *convert_PrioChannelInfos();
  27.  
  28. #define CHAN_READ_INTERVAL    60
  29.  
  30. /* ARGSUSED */
  31. int arg_channelread (ad, args, arg)
  32. int                ad;
  33. char                **args;
  34. struct type_UNIV_UTCTime    **arg;
  35. {
  36.     char    *str;
  37.     UTC    utc;
  38.           
  39.     utc = (UTC) malloc (sizeof(struct UTCtime));
  40.     utc->ut_flags = UT_SEC;
  41.  
  42.     utc->ut_sec = CHAN_READ_INTERVAL;
  43.  
  44.     str = utct2str(utc);
  45.     *arg = str2qb (str, strlen(str), 1);
  46.     return OK;
  47. }
  48.  
  49. static ChannelInfo *convert_ChanReadResult();
  50.  
  51. /* ARGSUSED */
  52. int res_channelread (ad, id, dummy, result, roi)
  53. int    ad, id, dummy;
  54. register struct type_Qmgr_ChannelReadResult    *result;
  55. struct RoSAPindication    *roi;
  56. {
  57.     struct cons_opblk *op;
  58.  
  59.     if ((op = find_copblk(ad, id)) == NULL)
  60.         return NOTOK;
  61.     
  62.     if (op -> fnx)
  63.         (*op -> fnx)(convert_ChanReadResult(result), id);
  64.     free_copblk(op);
  65.     return OK;
  66. }
  67.  
  68. /*   */
  69.  
  70. static CMD_TABLE control_tbl[] = {
  71.     CTRL_ENABLE,    type_Qmgr_Control_start,
  72.     CTRL_DISABLE,    type_Qmgr_Control_stop,
  73.     CTRL_CACHECLEAR,type_Qmgr_Control_cacheClear,
  74.     CTRL_CACHEADD,    type_Qmgr_Control_cacheAdd,
  75.     NULLCP,        NOTOK
  76.     };
  77.  
  78. /* ARGSUSED */ 
  79. int arg_channelcontrol (ad, args, arg)
  80. int                ad;
  81. char                **args;
  82. struct type_Qmgr_ChannelControl    **arg;
  83. /* args[0] = channel */
  84. /* args[1] = stop,start,clear,cacheadd */
  85. /* args[2] = time */
  86. {
  87.     int n;
  88.  
  89.     *arg = (struct type_Qmgr_ChannelControl *) malloc(sizeof(**arg));
  90.     (*arg)->control = (struct type_Qmgr_Control *)
  91.         malloc(sizeof(struct type_Qmgr_Control));
  92.  
  93.     (*arg)->channel = str2qb(args[0], strlen(args[0]), 1);
  94.  
  95.     if ((n = cmd_srch (args[1], control_tbl)) == NOTOK)
  96.         return NOTOK;
  97.     if (((*arg)->control->offset = n) == type_Qmgr_Control_cacheAdd) {
  98.         char    *timestr;
  99.  
  100.         timestr = mystrtotime(args[2]);
  101.         (*arg)->control->un.cacheAdd = str2qb(timestr,
  102.                               strlen(timestr),1);
  103.         free(timestr);
  104.     }
  105.     return OK;
  106. }
  107.  
  108. /* ARGSUSED */
  109. int res_channelcontrol (ad, id, dummy, result, roi)
  110. int    ad, id, dummy;
  111. register struct type_Qmgr_PrioritisedChannelList    *result;
  112. struct RoSAPindication    *roi;
  113. {
  114.     struct cons_opblk *op;
  115.  
  116.     if ((op = find_copblk(ad, id)) == NULL)
  117.         return NOTOK;
  118.     
  119.     if (op -> fnx)
  120.         (*op -> fnx)(convert_PrioChannelInfos(result), id);
  121.     free_copblk(op);
  122.     return OK;
  123. }
  124.  
  125. /*   */
  126.  
  127. static ChannelInfo    *convert_ChannelInfo(pepsy)
  128. register struct type_Qmgr_ChannelInfo    *pepsy;
  129. {
  130.     ChannelInfo    *ret;
  131.  
  132.     if (pepsy == (struct type_Qmgr_ChannelInfo *) NULL)
  133.         return (ChannelInfo *) NULL;
  134.  
  135.     ret = (ChannelInfo *) calloc (1, sizeof(*ret));
  136.  
  137.     ret->channelname = qb2str(pepsy->channel);
  138.     ret->channeldescrip = qb2str(pepsy->channelDescription);
  139.  
  140.     ret->oldestMessage = convert_time(pepsy->oldestMessage); 
  141.     ret->numberMessages = pepsy->numberMessages;
  142.     ret->numberReports = pepsy->numberReports;
  143.     ret->volumeMessages = pepsy->volumeMessages;
  144.     ret->numberMtas = pepsy->numberMtas;
  145.     ret->numberActiveProcesses = pepsy->numberActiveProcesses;
  146.     ret->status = convert_ProcStatus(pepsy->status);
  147.     ret->inbound = bit_test(pepsy->direction, bit_Qmgr_direction_inbound);
  148.     ret->outbound = bit_test(pepsy->direction, bit_Qmgr_direction_outbound);
  149.     ret->chantype = pepsy->chantype;
  150.     ret->maxprocs = pepsy->maxprocs;
  151.     ret->numberMtas = pepsy->numberMtas;
  152.  
  153.     return ret;
  154. }    
  155.  
  156. static ChannelInfo    *convert_PrioChannelInfos(pepsy)
  157. register struct type_Qmgr_PrioritisedChannelList    *pepsy;
  158. {
  159.     ChannelInfo    *head, *tail, *temp;
  160.     
  161.     head = tail = (ChannelInfo *) NULL;
  162.     
  163.     while (pepsy != (struct type_Qmgr_PrioritisedChannelList *) NULL) {
  164.         if ((temp = 
  165.              convert_ChannelInfo(pepsy->PrioritisedChannel->channel))
  166.             == (ChannelInfo *) NULL) {
  167.             free_ChannelInfo(head);
  168.             return (ChannelInfo *) NULL;
  169.         }
  170.         temp -> priority =
  171.             pepsy -> PrioritisedChannel -> priority -> parm;
  172.         if (head == NULL)
  173.             head = tail = temp;
  174.         else {
  175.             tail -> next = temp;
  176.             tail = temp;
  177.         }
  178.         pepsy = pepsy -> next;
  179.     }
  180.     return head;
  181. }
  182.  
  183. static ChannelInfo    *convert_ChanReadResult(pepsy)
  184. register struct type_Qmgr_ChannelReadResult    *pepsy;
  185. {
  186.     return convert_PrioChannelInfos(pepsy -> channels);
  187. }
  188.  
  189. /*   */
  190.  
  191. free_ChannelInfo(list)
  192. ChannelInfo    *list;
  193. {
  194.     ChannelInfo    *temp;
  195.  
  196.     while (list != (ChannelInfo *) NULL) {
  197.         if (list -> channelname) free (list -> channelname);
  198.         if (list -> channeldescrip) free (list -> channeldescrip);
  199.         if (list -> status) free_ProcStatus (list -> status);
  200.         temp = list;
  201.         list = list -> next;
  202.         free ((char *) temp);
  203.     }
  204. }
  205.  
  206.     
  207.